package org.ch02.test00.demo02;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/**
 * @author ZQX
 * @date 2025-03-19
 */

/**
 * 三、遍历Integer类中所有的字段，格式如下所示
 * public final class Integer {
 * public static final int MIN_VALUE;
 * public static final int MAX_VALUE;
 * public static final Class TYPE;
 * static final char[] digits;
 * static final char[] DigitTens;
 * static final char[] DigitOnes;
 * static final int[] sizeTable;
 * private final int value;
 * public static final int SIZE;
 * public static final int BYTES;
 * private static final long serialVersionUID;
 * }
 */
public class MainTest {
    public static void main(String[] args) throws Exception {
        Class<Integer> stu = Integer.class;
        Field[] fie = stu.getDeclaredFields();

        String integerName = stu.getSimpleName();
        String integerModifiers = Modifier.toString(stu.getModifiers());

        System.out.println(integerModifiers + " class " + integerName + "{");
        for (Field field : fie) {
            String fieldTypeName = field.getType().getSimpleName();
            int modifiers = field.getModifiers();
            String fieldModifier = Modifier.toString(modifiers);
            String fieldName = field.getName();
            System.out.println("\t" + fieldModifier + " " + fieldTypeName + " " + fieldName);
        }
        System.out.println("}");
    }
}
